/**
 * Project Name:FriedGoldenFlower
 * File Name:FragmentMain.java
 * Package Name:com.snail.fragment
 * Date:May 20, 201310:48:24 PM
 * Copyright (c) 2013, lilinfeng.abel@gmail.com All Rights Reserved.
 *
 */
package com.snail.fragment;

import com.snail.activity.R;

import android.app.Activity;
import android.os.Bundle;
import android.support.v4.app.Fragment;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.ImageView;

/**
 * ClassName: FragmentMain <br/>
 * Function: TODO ADD FUNCTION. <br/>
 * Reason: TODO ADD REASON(可选). <br/>
 * date: May 20, 2013 10:48:24 PM <br/>
 * 
 * @author lilinfeng.abel@gmail.com
 * @version
 * @since JDK 1.6
 */

public class FragmentMain extends FragmentBase implements View.OnClickListener {

	private View mView;
	private OnGameTypeClicked mOnGameTypeClicked;

	private ImageView ivQuickStart, ivGameHall, ivGameEvent;

	@Override
	public void onCreate(Bundle savedInstanceState) {
		super.onCreate(savedInstanceState);
	}

	@Override
	public View onCreateView(LayoutInflater inflater, ViewGroup container,
			Bundle savedInstanceState) {
		mView = inflater.inflate(R.layout.fragment_main, null);
		findViews();
		return mView;
	}

	@Override
	public void onAttach(Activity activity) {
		super.onAttach(activity);
		try {
			mOnGameTypeClicked = (OnGameTypeClicked) activity;
		} catch (ClassCastException e) {
			throw new ClassCastException(activity.toString()
					+ "must implement OnGameTypeClicked");
		}
	}

	private void findViews() {
		ivQuickStart = (ImageView) mView
				.findViewById(R.id.ivFragmentMainQuickStart);
		ivGameHall = (ImageView) mView
				.findViewById(R.id.ivFragmentMainGameHall);
		ivGameEvent = (ImageView) mView
				.findViewById(R.id.ivFragmentMainGameEvent);
		ivQuickStart.setOnClickListener(this);
		ivGameEvent.setOnClickListener(this);
		ivGameHall.setOnClickListener(this);
	}

	/**
	 * 
	 * ClassName: OnGameTypeClicked <br/>
	 * Function: TODO 回调接口， 当点击相应的ImageView的时候触发相应的时间 <br/>
	 * Reason: TODO ADD REASON(可选). <br/>
	 * date: May 25, 2013 9:08:29 PM <br/>
	 *
	 * @author lilinfeng.abel@gmail.com
	 * @version FragmentMain
	 * @since JDK 1.6
	 */
	public interface OnGameTypeClicked {
		
		public void onQuickStartClick(View v);

		public void onGameHallClick(View v);

		public void onGameEvent(View v);
	}

	/**
	 * TODO 简单描述该方法的实现功能（可选）.
	 * 
	 * @see android.view.View.OnClickListener#onClick(android.view.View)
	 */
	@Override
	public void onClick(View v) {
		if (mOnGameTypeClicked != null) {
			if (v.getId() == R.id.ivFragmentMainGameEvent) {
				mOnGameTypeClicked.onGameEvent(v);
			} else if (v.getId() == R.id.ivFragmentMainQuickStart) {
				mOnGameTypeClicked.onQuickStartClick(v);
			} else if (v.getId() == R.id.ivFragmentMainGameHall) {
				mOnGameTypeClicked.onGameHallClick(v);
			}
		}
	}

}
